package com.bing.bingPro.util;


import com.alibaba.excel.write.handler.WriteHandler;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;

/**
 * Excel数据封装
 *
 * @author qc-zhao
 */
public class ExcelData {

    /**
     * sheet名称
     */
    private String sheetName;

    /**
     * 实体类 class
     */
    private Class<?> clazz;

    /**
     * 数据集合
     */
    private Collection<?> data;

    private Collection<WriteHandler> registerWriteHandlers = new ArrayList<>();

    public ExcelData() {
        super();
    }

    /**
     * @param clazz 实体类
     * @param data  数据
     */
    public ExcelData(Class<?> clazz, Collection<?> data) {
        this.clazz = clazz;
        this.data = data;
    }


    /**
     * @param sheetName sheetName
     * @param clazz     实体类
     * @param data      数据
     */
    public ExcelData(String sheetName, Class<?> clazz, Collection<?> data) {
        this.sheetName = sheetName;
        this.clazz = clazz;
        this.data = data;
    }

    /**
     * @param sheetName             sheetName
     * @param clazz                 实体类
     * @param data                  数据
     * @param registerWriteHandlers 自定义样式
     */
    public ExcelData(String sheetName, Class<?> clazz, Collection<?> data, Collection<WriteHandler> registerWriteHandlers) {
        this.sheetName = sheetName;
        this.clazz = clazz;
        this.data = data;
        this.registerWriteHandlers = registerWriteHandlers;
    }

    public ExcelData(Class<?> clazz, Collection<?> data, Collection<WriteHandler> registerWriteHandlers) {
        this.clazz = clazz;
        this.data = data;
        this.registerWriteHandlers = registerWriteHandlers;
    }



    /**
     * @param sheetName             sheetName
     * @param clazz                 实体类
     * @param data                  数据
     * @param registerWriteHandlers 自定义样式
     */
    public ExcelData(String sheetName, Class<?> clazz, Collection<?> data, WriteHandler... registerWriteHandlers) {
        this.sheetName = sheetName;
        this.clazz = clazz;
        this.data = data;
        this.registerWriteHandlers.addAll(Arrays.asList(registerWriteHandlers));

    }


    public ExcelData(Class<?> clazz, Collection<?> data, WriteHandler... registerWriteHandlers) {
        this.clazz = clazz;
        this.data = data;
        this.registerWriteHandlers.addAll(Arrays.asList(registerWriteHandlers));

    }

    public String getSheetName() {
        return sheetName;
    }

    public void setSheetName(String sheetName) {
        this.sheetName = sheetName;
    }

    public Class<?> getClazz() {
        return clazz;
    }

    public void setClazz(Class<?> clazz) {
        this.clazz = clazz;
    }

    public Collection<?> getData() {
        return data;
    }

    public void setData(Collection<?> data) {
        this.data = data;
    }


    public void setRegisterWriteHandlers(Collection<WriteHandler> registerWriteHandlers) {
        this.registerWriteHandlers = registerWriteHandlers;
    }
}